<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>质量参数列表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="./css/UlStyle.css" rel="stylesheet">
<link href="./css/BtnStyle.css" rel="stylesheet">
<style type="text/css">
ul li img {
	width: 7em;
	height: 7em;
	display: inline;
	float: right;
}

.li_body {
	margin-top: 0.5em;
	height: 4.5em;
	line-height: 4.5em;
}

.li_body a {
	padding-left: 0.7em;
}

.submitTitle {
	width: 100%;
	min-height: 1em;
	font-size: 2.8em;
	background-color: #009688;
	margin: 0
}

.btn {
	margin-left: 70%;
}
</style>
<script type="text/javascript" src="./plugins/jquery-1.8.2.min.js">
</script>
	<script type="text/javascript" src="./plugins/jquery.cookie.js"></script>
<script type="text/javascript">

    $(document).ready(function(){

    });
	var ScCode = "";
	var OrderName = "";
	var LorderData = null ,BQParamsData = null;
	window.onload = function loading() {
		getParams();
	}
	function getParams() {
		var ss = decodeURI(location.search.replace('?', ''));
		var arr = ss.split("&");
		ScCode = arr[0];
		OrderName = arr[1];

	//	alert("参数信息：SCcode-》" + ScCode + "OrderName-》" + OrderName);
		//查询上序信息（附近前6个序，避免串并关系）
		getInfoByAjax('LastOrders', ScCode, OrderName);
	}

	//公用ajax
	function getInfoByAjax(searchText, searchValue, searchValue2) {
		$.ajax({
			type : "post",
			url : "servlet/SearchInfoServlet",
			data : {
				paramName : searchText,
				paramText : searchValue,
				paramText2 : searchValue2,
			},
			dataType : "json",
			success : function(data, textStatus) {
			//	alert("上序信息" + JSON.stringify(data));
				switch (searchText) {
				case "LastOrders":
				    LorderData = data;
				    getInfoByAjax('BQParamLists',ScCode,OrderName);
					break;
				case "BQParamLists":
				    BQParamsData = data;
				    loadingParamsList();
				default :
				    break;

				}
				

			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				alert("生产计划查询失败，请重试！"); //+ textStatus + errorThrown
			}
		});

	}

    //动态加载上序信息及本序质量参数列表
    function loadingParamsList(){
        
        var body = "";
		$("#Div_ParamsList").empty();	
       
        if(LorderData.length != 0){   
             //上序信息加载     
          //   alert("加载上序信息");
			 if(LorderData[0]['EvalResult'] == '合格'){
				 body += "<ul>";
				 body += "<li class=\"li_head\"><a>反馈上序</a><img alt=\"待评价\" src=\"./img/icon_hg.png\"></li>"
			 }else if(LorderData[0]['EvalResult'] == '不合格'){
				 body += "<ul>";
				 body += "<li class=\"li_head\"><a>反馈上序</a><img alt=\"待评价\" src=\"./img/icon_bhg.png\"></li>"
			 }else{
				 body += "<ul onclick=\"jumpOrderSubmitJsp('"+LorderData+"')\">";
				 body += "<li class=\"li_head\"><a>反馈上序</a><img alt=\"待评价\" src=\"./img/icon_dpj.png\"></li>"
			 }
             body += "<li class=\"li_body\"><a>工序编号："+LorderData[0]['Gx_Code']+"</a></li>"
                     +"<li class=\"li_body\"><a>工序名称："+LorderData[0]['Gx_Name']+"</a></li>"
                     +"<li class=\"li_body\"><a>责任班组：<a id='Team1'>"+LorderData[0]['JH_Zx_Bz']+"</a></a ></li>"
                     +"</ul>" ;
             //alert("加载上序信息完毕");	 	  
       
        }
       
       if(BQParamsData.length != 0){

       		var EvDone = [];
       		var EvNotDone = [];
           for ( var i = 0; i < BQParamsData.length; i++) {
             var evalResult = BQParamsData[i]['EvalResult'];

			   if(evalResult != ''){
				   EvDone.push(BQParamsData[i]);
			   }else{
				   EvNotDone.push(BQParamsData[i]);
			   }
		   }

           for(var i =0; i< EvDone.length; i++){
			   body += ("<p class=\"submitTitle\">&nbsp;&nbsp;&nbsp;已汇报列表：</p>");


			   if(evalResult == '不合格'){
				   body += ("<ul >"
						   +"<li class=\"li_head\"><a>本序质量</a><img alt=\"待评价\" src=\"./img/icon_bhg.png\"></li>");
			   }else {
				   body += ("<ul >"
						   +"<li class=\"li_head\"><a>本序质量</a><img alt=\"待评价\" src=\"./img/icon_hg.png\"></li>");
			   }

			   body += ("<li class=\"li_body\"><a>参数名称："+BQParamsData[i]['Param_Name']+"</a></li>"
					   +"<li class=\"li_body\"><a>责任工序："+OrderName+"</a></li>"
					   +"<li class=\"li_body\"><a>责任班组：<a id='Team2'>"+BQParamsData[i]['JH_Zx_Bz']+"</a></a></li>"
					   +"</ul>");

		   }

		   for(var i =0; i< EvNotDone.length; i++){
			   body += ("<p class=\"submitTitle\">&nbsp;&nbsp;&nbsp;未汇报列表：</p>");


			   if(evalResult == '' ){
				   flag = true;
				   body += ("<ul onclick=\"jumpParamSubmitJsp("+i+")\">"
						   +"<li class=\"li_head\"><a>本序质量</a><img alt=\"待评价\" src=\"./img/icon_dpj.png\"></li>");
			   }

			   body += ("<li class=\"li_body\"><a>参数名称："+BQParamsData[i]['Param_Name']+"</a></li>"
					   +"<li class=\"li_body\"><a>责任工序："+OrderName+"</a></li>"
					   +"<li class=\"li_body\"><a>责任班组：<a id='Team2'>"+BQParamsData[i]['JH_Zx_Bz']+"</a></a></li>"
					   +"</ul>");
		   }

		   if(EvNotDone.length == 0){
		        body += "<button id=\"submitBtn\" class=\"btn change3\"><span>完工汇报</span></button>";
		   }

       }else{
		   body += "<button id=\"submitBtn\" class=\"btn change3\"><span>完工汇报</span></button>";
	   }
       
       
       $("#Div_ParamsList").append(body);
	   $("#Div_ParamsList").show();
	   body = "";

        $('#submitBtn').click(function(){
			var userName  = $.cookie('name');
            $.post('servlet/SearchInfoServlet',{paramName:'Report',ScOrder:ScCode,GxCode:OrderName,UserCode:userName},function(data){
					window.location.href = "./Jsp/QsHome.jsp?"
			});
        })
    
    }

	function jumpParamSubmitJsp(i) {

		window.location.href = "./Jsp/SelfAssessment.jsp?"+BQParamsData[i]['Param_Name']
		+"&"+BQParamsData[i]['ParamType']+"&"+BQParamsData[i]['TestStandard']+"&"+BQParamsData[i]['Standard']+"&"
		+BQParamsData[i]['QualitativeDescribe']+"&"+BQParamsData[i]['MinValue']+"&"+BQParamsData[i]['MaxValue']+"&"+BQParamsData[i]['Id'];

	}

	function jumpOrderSubmitJsp() {
	
		window.location.href = "./Jsp/BeforeOrder.jsp?"+ScCode+"&"+OrderName;

	}
</script>
</head>

<body
	style="background-color: #F0F0F0;padding-left: 0em;padding-right: 0em;">
	<div style="width:100%;" id="Div_ParamsList">
		
	</div>
</body>
</html>